The present disclosure relates generally to the field of data processing, and, more particularly, to the testing of lock managers in computing environments.
Locking schemes are used in many computing environments to help prevent conflicts like those that can occur when multiple entities (e.g., applications, processes) attempt to access a file concurrently. These conflicts can be resolved through recourse to a lock manager, which may be a component of a file system, an operating system kernel, or a specialized application. Unix-like operating systems commonly implement lock in a file system or an operating system kernel, exposing system calls, such as fcntl and flock, as interfaces between the processes accessing the locks and the lock manager. Some locking mechanisms, such as Linux's flock, only allow locking at the file level. Others, like the POSIX fcntl interface, allow file locking on individual bytes or byte ranges. These locks are referred to as record locks.
Locks may be mandatory or advisory. Mandatory locks are enforced by the operating system, and may prevent all access to locked objects from any entities not holding a lock. Under an advisory locking scheme, entities agree to use a particular locking scheme as implemented by a particular lock manager when acquiring and dropping locks.
Because advisory locks are not mandatory, they are only enforced by the lock manager when its APIs are invoked. This means that every read and write on a file is not being checked for legality by the lock manager, as in a mandatory locking system. This may result in increased performance. However, the tradeoff is that a buggy application (e.g., one with incorrect locking code) or an application that is designed to ignore advisory locks can interfere with applications correctly using the advisory locks.
Locks may be exclusive (“write”) or shared/non-exclusive (“read”). At most one entity at a time can hold an exclusive lock on an object (e.g., a file). One or more entities may hold a shared lock on an object. Exclusive and shared locks are mutually exclusive: no shared locks can be held when an entity holds an exclusive lock is held, and no exclusive locks can be held when at least one entity holds a shared lock.